//
//  KSStartCarLoadingViewController.swift
//  Supermarket
//
//  Created by liuxm on 2017/10/12.
//  Copyright © 2017年 kushao. All rights reserved.
//

import UIKit

/// 开始装车
class KSStartCarLoadingViewController: KSBaseViewController {

    @IBOutlet weak var noticeLabel: UILabel!
    
    @IBOutlet weak var orderNoLabel: UILabel!
    
    @IBOutlet weak var switchOrderBtn: UIButton!
    
    @IBOutlet weak var tableView: UITableView!
    
    @IBOutlet weak var sendBtn: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        self.title = "开始装车"
        
        self.tableView.dataSource = self
        self.tableView.delegate = self
        self.tableView.separatorColor = KSColor.kColor_line
        self.tableView.backgroundColor = KSColor.kColorViewBackground
        
        let addressNib = UINib(nibName: "KSAddressTableViewCell", bundle: nil)
        self.tableView.register(addressNib, forCellReuseIdentifier: "KSAddressTableViewCell")
        
        let detailNib = UINib(nibName: "KSPickingGoodsDetailTableViewCell", bundle: nil)
        self.tableView.register(detailNib, forCellReuseIdentifier: "KSPickingGoodsDetailTableViewCell")
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    // 点击发车 按钮变成已送达
    @IBAction func sendBtnClick(_ sender: Any) {
        
    }
    
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}

extension KSStartCarLoadingViewController: UITableViewDelegate, UITableViewDataSource {
    // UITableViewDataSource
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return 3
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    
    // UITableViewDelegate
    
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        var height = 10
        if section == 0 {
            height = 1
        }
        
        return CGFloat(height)
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        var height = 210.0
        if indexPath.section == 0 {
            height = 90.0
        }
        
        return CGFloat(height)
    }
    
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0.1
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if indexPath.section == 0 {
            let cell = tableView.dequeueReusableCell(withIdentifier: "KSAddressTableViewCell", for: indexPath) as! KSAddressTableViewCell

            return cell
        }
        
        let cell = tableView.dequeueReusableCell(withIdentifier: "KSPickingGoodsDetailTableViewCell", for: indexPath) as! KSPickingGoodsDetailTableViewCell
        
        return cell
    }
}
